<template>
	<view>
		<view class="cu-list menu">
			<view class="login-user-info">
				<image class="user-avatar" :src="userInfo.avatar" mode=""></image>
				<view class="user-test-info">
					<text class="user-name">{{userInfo.nickName}}</text>
					<text class="user-tel">{{shopInfo.tel}}</text>
				</view>
<!-- 				<view class="shop-state" v-if="isshow">
					<text>营业状态</text>
					<switch @change="shopChange" color="#FF203B" style="transform:scale(0.7)" :checked="status == 0"/>
				</view> -->
			</view>
			<view class="cu-item arrow" data-page_name="card/card" @tap="toCard()">
				<view class="content">
					<image src="../../static/images/huiyuan.png"></image>
					<text class="menu-name">会员卡</text>
				</view>
			</view>
			<view class="cu-item arrow" data-page_name="my_appointment" @tap="toOrderList()">
				<view class="content">
					<image src="../../static/images/shijian.png"></image>
					<text class="menu-name">预约列表</text>
				</view>
			</view>
	<!-- 		<view class="cu-item arrow" data-page_name="capital_account" @tap="jumpTo">
				<view class="content">
					<image src="../../static/images/qiaqia.png"></image>
					<text class="menu-name">资金账户</text>
				</view>
			</view> -->
<!-- 			<view class="cu-item arrow" data-page_name="my_sharing" @tap="jumpTo">
				<view class="content">
					<image src="../../static/images/fenxiang.png"></image>
					<text class="menu-name">我的分享</text>
				</view>
			</view> -->
			<view class="cu-item arrow" data-page_name="store_settlement" @tap="jumpTo" v-if="!isshow">
				<view class="content">
					<image src="../../static/images/paihang.png"></image>
					<text class="menu-name">店铺入驻</text>
				</view>
			</view>
			<view class="cu-item arrow" data-page_name="business_manage/store_manage" @tap="jumpTo" v-if="isshow">
				<view class="content">
					<image src="../../static/images/jingxuan.png"></image>
					<text class="menu-name">商家管理</text>
				</view>
			</view>
		</view>
		<view class="cu-list menu margin-top" v-if="isshow">
			<view class="cu-item arrow"  v-if="isshow">
				<view class="content s-state">
					<image src="../../static/images/shopstate.png"></image>
					<text class="menu-name">营业状态</text>
					<switch @change="shopChange" color="#FF203B" style="transform:scale(0.9);margin-right: -30rpx;" :checked="status == 0"/>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {getShopByUserId,businessStatusSwitch} from '@/api/index.js';
	import config from '@/config/index';
	export default {
		data() {
			return {
				isshow:false,
				userInfo:{},
				shopInfo:{},
				status:1,//店铺状态  默认 1 休息中 0 营业中
			}
		},
		onShow() {
			this.userInfo = uni.getStorageSync('userInfo')
			console.log(this.userInfo);
			getShopByUserId({}).then(res=>{
				this.shopInfo = res
				console.log(res)
				this.status = res.status	
				uni.setStorageSync('shopnames',res.shopName)
				if(res.review == 0){
					this.isshow = true
				}
			})
		},
		// mounted() {

		// },
		methods: {
			toCard(){
				uni.switchTab({  
					url: 'card/card'  
				});  
			},
			toOrderList(){
				uni.switchTab({  
					url: 'my_appointment'  
				});  
			},
			shopChange: function (e) {
				console.log('switch1 发生 change 事件，携带值为', e.target.value)
				businessStatusSwitch().then(re =>{
				}).catch(re=>{
					console.log(re);
				});
			},
			jumpTo(e) {
				var pageName = e.currentTarget.dataset.page_name;
				//在起始页面跳转到test.vue页面并传递参数
				uni.navigateTo({
					url: pageName
				});
			},
			showModal(e) {
				this.modalName = e.currentTarget.dataset.target
			},
			hideModal(e) {
				this.modalName = null
			}
		},
	}
</script>

<style>
	@import "../../static/css/me.css";
</style>
